import { IsEmail, IsString, IsOptional, MinLength, MaxLength } from 'class-validator';
import mongoose from 'mongoose';
export class CreateUserDto {
  @IsString({ message: '姓名必须是字符串' })
  @MinLength(2, { message: '姓名长度不能小于2个字符' })
  @MaxLength(50)
  name!: string;

  @IsEmail({}, { message: '请输入正确的邮箱格式' })
  email!: string;

  @IsString()
  @MinLength(6, { message: '密码长度不能小于6个字符' })
  password!: string;


  @IsOptional()
  @IsString({ message: '头像必须是字符串' })
  avatar?: string;
  @IsOptional()
  @IsString({ message: '创建人必须是字符串' })
  createdBy!: mongoose.Schema.Types.ObjectId;
}
export class LoginDto {
  @IsEmail({}, { message: '邮箱格式不正确' })
  email!: string;

  @IsString({ message: '密码必须是字符串' })
  @MinLength(6, { message: '密码至少需要6个字符' })
  password!: string;
}
export class RegisterDto {
  @IsString({ message: '姓名必须是字符串' })
  @MinLength(2, { message: '姓名至少需要2个字符' })
  @MaxLength(50, { message: '姓名不能超过50个字符' })
  name!: string;

  @IsEmail({}, { message: '邮箱格式不正确' })
  email!: string;

  @IsString({ message: '密码必须是字符串' })
  @MinLength(6, { message: '密码至少需要6个字符' })
  password!: string;

}

export class UpdateUserDto {
  @IsOptional()
  @IsString({ message: '姓名必须是字符串' })
  @MinLength(2, { message: '姓名长度不能小于2个字符' })
  @MaxLength(50, { message: '姓名长度不能大于50个字符' })
  name?: string;

  @IsOptional()
  @IsEmail({}, { message: '邮箱格式无效' })
  email?: string;

  @IsOptional()
  @IsString({ message: '密码必须是字符串' })
  @MinLength(6, { message: '密码长度不能小于6个字符' })
  password?: string;


  @IsOptional()
  @IsString({ message: '头像必须是字符串' })
  avatar?: string;
  @IsOptional()
  @IsString({ message: '更新人必须是字符串' })
  updatedBy!: mongoose.Schema.Types.ObjectId;
}
